<?php

  /**
   * конфигурация менеджера авторизации
   */

  return array(
    "edit_profile" => array(
      "type"        => CAuthItem::TYPE_OPERATION,
      "description" => "Изменение профиля"
    ),

    "create_blog" => array(
      "type"        => CAuthItem::TYPE_OPERATION,
      "description" => "Создание блога"
    ),
    "edit_blog" => array(
      "type"        => CAuthItem::TYPE_TASK,
      "description" => "Изменение блога",
      "bizRule"     => 'return Yii::app()->user->id==$params["post"]->user_id;'
    ),
    "remove_blog" => array(
      "type"        => CAuthItem::TYPE_TASK,
      "description" => "Удаление блога",
      "bizRule"     => 'return Yii::app()->user->id==$params["post"]->user_id;'
    ),

    "create_news" => array(
      "type"        => CAuthItem::TYPE_OPERATION,
      "description" => "Создание новости"
    ),
    "edit_news" => array(
      "type"        => CAuthItem::TYPE_OPERATION,
      "description" => "Изменение новости"
    ),
    "remove_news" => array(
      "type"        => CAuthItem::TYPE_OPERATION,
      "description" => "Удаление новости"
    ),

    "create_public" => array(
      "type"        => CAuthItem::TYPE_OPERATION,
      "description" => "Создание публикации"
    ),
    "edit_public" => array(
      "type"        => CAuthItem::TYPE_OPERATION,
      "description" => "Изменение публикации"
    ),
    "remove_public" => array(
      "type"        => CAuthItem::TYPE_OPERATION,
      "description" => "Удаление публикации"
    ),

    "add_comment" => array(
      "type"        => CAuthItem::TYPE_OPERATION,
      "description" => "Добавление коммента"
    ),
    "remove_comment" => array(
      "type"        => CAuthItem::TYPE_TASK,
      "description" => "Удаление коммента",
      "bizRule"     => 'return strcasecmp($params["comment"]->originPost->type,Post::BLOGS)?!(Yii::app()->user->isGuest||strcasecmp(Yii::app()->user->role,User::MODERATOR)):Yii::app()->user->id==$params["comment"]->originPost->user_id;'
    ),

    "assess_credibility" => array(
      "type"        => CAuthItem::TYPE_TASK,
      "description" => "Оценка авторитетности",
      "bizRule"     => 'return Yii::app()->user->id!=$params["post"]->user_id;'
    ),
    "estimate" => array(
      "type"        => CAuthItem::TYPE_TASK,
      "description" => "Выставить оценку за публикацию",
      "bizRule"     => 'return Yii::app()->user->id!=$params["post"]->user_id;'
    ),

    User::GUEST => array(
      "type"        => CAuthItem::TYPE_ROLE,
      "description" => "Гость"
    ),
    User::USER => array(
      "type"        => CAuthItem::TYPE_ROLE,
      "description" => "Зарегистрированный пользователь",
      "children"    => array(User::GUEST, "edit_profile", "create_blog", "edit_blog", "remove_blog", "add_comment", "remove_comment", "assess_credibility")
    ),
    User::AUTOR => array(
      "type"        => CAuthItem::TYPE_ROLE,
      "description" => "Автор публикаций",
      "children"    => array(User::USER, "create_public", "estimate")
    ),
    User::MODERATOR => array(
      "type"        => CAuthItem::TYPE_ROLE,
      "description" => "Модератор",
      "children"    => array(User::AUTOR, "create_news", "edit_news", "remove_news", "edit_public", "remove_public")
    )
  );

?>